﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using System.Windows.Forms;

namespace 菜单和工具
{
    public partial class Form6 : Form
    {
        public Form6()
        {
            InitializeComponent();
            TimerInit(1000);
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {

        }
        void TimerInit(int time)
        {
            //系统定时器
            System.Timers.Timer timer;
            //高刷新定时器初始化
            timer = new System.Timers.Timer();
            timer.Interval = time;              // 单位：毫秒
            timer.Elapsed += OnTimedEvent;
            timer.AutoReset = true;
            timer.Enabled = true;
            timer.Start();
            //timer.Stop();
        }
        /* 定时器Timer触发事件
         */
        private void OnTimedEvent(object source, ElapsedEventArgs e)
        {
            Invoke(new EventHandler(delegate
            {
                progressBar1.Value += 10;
                if (progressBar1.Value >= 100)
                {
                    progressBar1.Value = 0;
                }
            }));
        }
    }
}
